Selection Sort Visualization

OVERVIEW


Selection Sort is a comparison-based sorting algorithm. It sorts an array by repeatedly selecting the smallest (or largest) element from the unsorted portion and swapping it with the first unsorted element. This process continues until the entire array is sorted.

Time Complexity


  • Best Case: O(n2)(even if already sorted, still scans the array).
  • Worst Case: O(n2)(when elements are in descending order).
  • Space Complexity: O(1)(in-place sorting, no extra space required).

Color Representation


  • Blue → Currently selected minimum element in the iteration.
  • Orange → Element being compared with the current minimum.
  • Red → Elements still unsorted.
  • Green → Elements that are sorted and in their final position.